package Day2025_03_26;

public class Demo04 {
    public int getLongestPalindrome (String A) {
        // write code here
        int n = A.length();
        boolean[][] isPali = new boolean[n][n];
        int ret = 0;
        for (int i = n - 1; i >= 0; i--) {
            for (int j = i; j < n; j++) {
                if (A.charAt(i) == A.charAt(j)) isPali[i][j] = i + 1 < j ? isPali[i + 1][j - 1] : true;
                if (isPali[i][j]) ret = Math.max(j - i + 1, ret);
            }
        }
        return ret;
    }
}
